package com.wanshi.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanshi.mapper.TiMapper;
import com.wanshi.po.Page;
import com.wanshi.po.RecordPo;
import com.wanshi.po.Timu;
import com.wanshi.po.TimuPo;
import com.wanshi.utils.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

@Service
public class TiService {

    @Autowired
    private TiMapper tiMapper;

    public Timu findById(String id) {
        return tiMapper.findById(id);
    }

    public void add(Timu timu) {
        tiMapper.add(timu);
    }

    public Page<TimuPo> list(int pagenum,int user_id) {
        PageHelper.startPage(pagenum, Constants.PAGE_SIZE);
        List<TimuPo> list = tiMapper.list(user_id);
        PageInfo<TimuPo> pageInfo = new PageInfo<>(list);

        Page<TimuPo> page = new Page<>();
        page.setList(pageInfo.getList());
        page.setCurpage(pagenum);
        page.setCount( (int)pageInfo.getTotal());

        return page;


    }
}
